//
//  CFProxySocket.h
//  SdkDemo
//
//  Created by HalloWorld on 2016/12/6.
//  Copyright © 2016年 legendsec. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef NS_ENUM(int16_t, CFProxySocketSOCKSVersion) {
    CFSocketSOCKSVersion4 = 0,    // Not implemented
    CFSocketSOCKSVersion4a,       // Not implemented
    CFSocketSOCKSVersion5         // WIP
};

@interface CFProxySocket : NSObject

// SOCKS proxy settings
@property (nonatomic, strong, readonly) NSString *proxyHost;
@property (nonatomic, readonly) uint16_t proxyPort;
@property (nonatomic, readonly) CFProxySocketSOCKSVersion proxyVersion;

@property (nonatomic, strong, readonly) NSString *proxyUsername;
@property (nonatomic, strong, readonly) NSString *proxyPassword;

@property (nonatomic, copy) void(^socketReadData)(NSData* data);
@property (nonatomic, copy) void(^socketDidConnected)(NSString* host, NSInteger port);
@property (nonatomic, copy) void(^socketConnectError)(NSError* error);

/**
 * SOCKS Proxy settings
 **/
- (void)setProxyHost:(NSString*)host port:(uint16_t)port version:(CFProxySocketSOCKSVersion)version;
- (void)setProxyUsername:(NSString *)username password:(NSString*)password;

- (BOOL)connectToHost:(NSString*)host onPort:(uint16_t)port;
- (void)sendStreamData:(NSData*)data completion:(void(^)(NSError* error))completion;

@end
